/*
When a shadow falls across your world,
and your enemy wants nothing but your annihilation.
Where will you find your allies,
in a desperate struggle for survival.
*/
#include <bits/stdc++.h>
using namespace std;
int T,p[100005],n,m,l,maxv,d[100005],v[100005],a[100005],anscar,ans2;
struct node{
    int l,r;
}c[100005];
bool cmp(node ktq,node xcx){
    if(ktq.l!=xcx.l)return ktq.l<xcx.l;
    return ktq.r>xcx.r;
}
priority_queue<int,vector<int>,greater<int> > q;
signed main(){
    freopen("detect.in","r",stdin);
    freopen("detect.out","w",stdout);
    scanf("%d",&T);    
    while(T--){
        anscar=ans2=0;
        scanf("%d%d%d%d",&n,&m,&l,&maxv);
        for(int i=1;i<=n;i++)scanf("%d%d%d",&d[i],&v[i],&a[i]);
        for(int i=1;i<=m;i++)scanf("%d",&p[i]);
        for(int i=1;i<=n;i++){
            if(d[i]>p[m])continue;
            if(a[i]==0){
                if(v[i]>maxv){
                    anscar++;
                    int pos=lower_bound(p+1,p+m+1,d[i])-p;
                    c[anscar].l=pos,c[anscar].r=m;
                }
            }
            else if(a[i]>0){
                if(v[i]>maxv){
                    anscar++;
                    int pos=lower_bound(p+1,p+m+1,d[i])-p;
                    c[anscar].l=pos,c[anscar].r=m;
                    continue;
                }
                double t=1.0*(maxv-v[i])/a[i];
                double dis=0.5*t*(v[i]+maxv);
                int endp=d[i]+floor(dis);
                int pos=upper_bound(p+1,p+m+1,endp)-p;
                if(pos>m)continue;
                anscar++;
                c[anscar].l=pos,c[anscar].r=m;
            }
            else{
                if(v[i]<=maxv)continue;
                double t=1.0*(v[i]-maxv)/(-a[i]);
                double dis=0.5*t*(v[i]+maxv);
                int endp=d[i]+ceil(dis);
                int posst=lower_bound(p+1,p+m+1,d[i])-p;
                int posend=lower_bound(p+1,p+m+1,endp)-p-1;
                if(posst>posend)continue;
                anscar++;
                c[anscar].l=posst,c[anscar].r=posend;
            }
        }
        sort(c+1,c+anscar+1,cmp);
        for(int i=1;i<=anscar;i++){
            if(!q.empty()&&q.top()<c[i].l){
                while(!q.empty())q.pop();
                ans2++;
            }
            q.push(c[i].r);
        }
        if(!q.empty())ans2++;
        while(!q.empty())q.pop();
        printf("%d %d\n",anscar,m-ans2);
    }
    return 0;
}